﻿using System.Collections.Generic;

public class ChessXiang : BaseChess
{
    private Pos[] directions = new Pos[4] { new Pos(-1, -1), new Pos(-1, 1), new Pos(1, -1), new Pos(1, 1) };
    public ChessXiang(int camp, int team) : base(camp, team)
    {

    }
    public override void AddSomePosIntoList(BaseChessBoard chessBoard, List<Pos> tempPosList)
    {
        BaseGrid grid = chessBoard.GetGridByChess(this);
        if (grid != null)
        {
            Pos chessPos = grid.GetPos();
            Pos endPos;
            for (int i = 0; i < directions.Length; i++)
            {
                Pos blockPos = chessPos.AddResult(directions[i]);
                if (chessBoard.SpaceIsGridAndNotExistChess(blockPos))
                {
                    endPos = chessPos.AddResult(directions[i].MulResult(2));
                    if (chessBoard.SpaceIsGridAndNotExistChess(endPos) || chessBoard.SpaceIsGridAndExistOtherTeamChess(endPos, GetTeam()))
                    {
                        BaseGrid endGrid = chessBoard.GetGridByPos(endPos);
                        StandardGrid sEndGrid = endGrid as StandardGrid;
                        if (sEndGrid != null && sEndGrid.GetCamp() == GetCamp())
                        {
                            tempPosList.Add(endPos);
                        }
                    }
                }
            }
        }
    }
    public override Score GetScore(BaseChessBoard baseChessBoard)
    {
        return new Score(4, 0);
    }
}